package pet;

class PetShop {
    private final Pet[] pets;
    public PetShop(int capacity) {

        this.pets = new Pet[capacity];
    }

    // 添加宠物
    public void addPet(Pet pet, int index) {
        pets[index] = pet;
    }

    // 根据平均值降序排列宠物
    public void sortPetsByAverage() {
        for (int i = 0; i < pets.length - 1; i++) {
            for (int j = 0; j < pets.length - i - 1; j++) {
                if (pets[j].getAverage() < pets[j + 1].getAverage()) {
                    Pet temp = pets[j];
                    pets[j] = pets[j + 1];
                    pets[j + 1] = temp;
                }
            }
        }
    }

    // 打印所有宠物信息
    public void printPetsInfo() {
        for (Pet pet : pets) {
            if (pet != null) {
                pet.printInfo();
            }
        }
    }
}
